package org.example;


import com.sun.tools.attach.VirtualMachine;

/**
 * https://zhuanlan.zhihu.com/p/636603910?utm_id=0
 */
public class AttachMain {
    public static void main(String[] args) {
        System.out.println("AttachMain类中的main方法执行了.---Runtime.getRuntime="+Runtime.getRuntime());
        try {
            VirtualMachine vm = VirtualMachine.attach("50372");
            vm.loadAgent("agent-attach/target/agent-attach-1.0-SNAPSHOT.jar",
                    "scy-attachMain");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}